import { requestClient } from '#/api/request';

export namespace WareStock {
  export interface Params {
    attr1: null;
  }
  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: null;
    updateBy: string;
    updateTime: Date | null;
    remark: null;
    params: Params;
    materialStockId: number;
    itemTypeId: number;
    itemId: number;
    itemCode: string;
    itemName: string;
    specification: null | string;
    unitOfMeasure: string;
    unitName: string;
    batchId: null | number;
    batchCode: null | string;
    warehouseId: number;
    warehouseCode: string;
    warehouseName: string;
    locationId: number;
    locationCode: string;
    locationName: string;
    areaId: number;
    areaCode: string;
    areaName: string;
    quantityOnhand: number;
    recptDate: Date;
    frozenFlag: string;
  }

  export interface GetListParams {
    pageNum: number;
    pageSize: number;
    itemTypeId?: string;
  }
  export interface GetListReturn {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}
export namespace WareStockTree {
  export interface FluffyChild {
    id: number;
    label: string;
  }
  export interface PurpleChild {
    id: number;
    label: string;
    children?: FluffyChild[];
  }
  export interface DatumChild {
    id: number;
    label: string;
    children: PurpleChild[];
  }
  export interface Datum {
    id: number;
    label: string;
    children: DatumChild[];
  }

  export interface GetListReturn {
    msg: string;
    code: number;
    data: Datum[];
  }
}

// 获取列表

export const getWareStockTableList = (params: WareStock.GetListParams) =>
  requestClient.get<WareStock.GetListReturn>('/mes/wm/wmstock/list', {
    params,
  });
export const updateWareStockStatus = (data: {
  frozenFlag: string;
  materialStockId: string;
}) => requestClient.put<WareStock.GetListReturn>('/mes/wm/wmstock', data);
export const getWareStockTreeSelect = () =>
  requestClient.get<WareStockTree.GetListReturn>('/mes/md/itemtype/treeselect');
